﻿using System.Collections;
using UnityEngine;

namespace Easy.Game2d
{
    public class BulletItem : MonoBehaviour
    {
        public bool _isChuanTou = false;
        public int damage = 1;
        private void Start()
        {
            StartCoroutine(WaitHide());
        }

        public   void OnTriggerEnter2D(Collider2D collision)
        {
            if (collision.CompareTag("Monster"))
            {
                if(!_isChuanTou) StartCoroutine(WaitDes());

            }
        }
        private IEnumerator WaitDes()
        {
            this.transform.localScale = new Vector3(0, 0, 0);
            yield return new WaitForSeconds(2);
            Destroy(this.gameObject);
        }

        private IEnumerator WaitHide()
        {
            yield return new WaitForSeconds(15);
            this.transform.localScale = new Vector3(0, 0, 0);
            yield return new WaitForSeconds(1);
            Destroy(this.gameObject);
        }
    }
}
